<?xml version="1.0" encoding="utf-8" ?> 
<sqlMap namespace="SendMessage"
	xmlns="http://ibatis.apache.org/mapping" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<alias>
		<typeAlias alias="SendMessage" type="Domain.SendMessage" />
	</alias>

	<resultMaps>
		<resultMap id="FullResultMap" class="SendMessage">
			<result property="id" column="id" dbType="Int"/>
			<result property="orderID" column="orderID" dbType="NVarChar"/>
			<result property="expressCorp" column="expressCorp" dbType="NVarChar"/>
			<result property="billNo" column="billNo" dbType="NVarChar"/>
			<result property="receiverName" column="receiverName" dbType="NVarChar"/>
			<result property="sendtime" column="sendtime" dbType="SmallDateTime"/>
			<result property="orderSchedule" column="orderSchedule" dbType="NVarChar"/>
		</resultMap>
	</resultMaps>
	
	<statements>

		<select id="GetCount" resultClass="System.Int32">
			SELECT count(*) FROM [dbo].[sendMessage]
		</select>
		
		<select id="GetCountByCondition" parameterClass="Hashtable" resultClass="System.Int32" extends="GetCount">
			WHERE $condition$
		</select>
		
		<select id="FindAll" resultClass="SendMessage">
			SELECT * 
			FROM [dbo].[sendMessage]
		</select>
		
		<select id="GetModel" parameterClass="SendMessage" resultClass="SendMessage" extends="FindAll">
			WHERE
				([sendMessage].[id] = #id,dbType=Int#)
		</select>

		<insert id="Insert" parameterClass="SendMessage">
			INSERT INTO [dbo].[sendMessage] (
				
				[orderID] , 
				[expressCorp] , 
				[billNo] , 
				[receiverName] , 
				[sendtime] , 
				[orderSchedule]
			) VALUES (
				
				 #orderID,dbType=NVarChar# , 
				 #expressCorp,dbType=NVarChar# , 
				 #billNo,dbType=NVarChar# , 
				 #receiverName,dbType=NVarChar# , 
				 #sendtime,dbType=SmallDateTime# , 
				 #orderSchedule,dbType=NVarChar#
			)
		</insert>

		<update id="Update" parameterClass="SendMessage">
			UPDATE [dbo].[sendMessage] SET
				 [orderID] = #orderID,dbType=NVarChar#
				, [expressCorp] = #expressCorp,dbType=NVarChar#
				, [billNo] = #billNo,dbType=NVarChar#
				, [receiverName] = #receiverName,dbType=NVarChar#
				, [sendtime] = #sendtime,dbType=SmallDateTime#
				, [orderSchedule] = #orderSchedule,dbType=NVarChar#
			WHERE
				([id] = #id,dbType=Int#)
		</update>

		<delete id="Delete" parameterClass="SendMessage">
			DELETE FROM [dbo].[sendMessage]
			WHERE
				([id] = #id,dbType=Int#)
		</delete>

		<select id="GetModelsByCondition" parameterClass="Hashtable" resultClass="SendMessage">
			SELECT $columnNames$ FROM [dbo].[sendMessage] where $condition$
		</select>
		
		<select id="GetModelsByConditionByPager" parameterClass="Hashtable" resultClass="SendMessage">
      declare @indextable table(rno int identity(1,1),nid int)
      insert into @indextable(nid) select [id] from [dbo].[sendMessage]
      where $condition$ order by $orderBy$

      select $columnNames$ from
      [dbo].[sendMessage] ,@indextable t
      <![CDATA[
			where t.nid= [sendMessage].id and t.rno>#startNo# and t.rno<=#endNo# 
      order by t.rno asc
			]]>
		</select>
		
	</statements>
</sqlMap>
